package ru.hh.team02.chat.messaging;

import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;

import org.junit.Test;

import ru.hh.team02.chat.client.Client;

public class SendingQueueTest {

    @Test
    public void shouldRecepientBeSentMessageAddedToTheQueue() {
        // given
        Message message = new Message("Test message");

        Client client = mock(Client.class);
        SendingQueue queue = new SendingQueue(1, client);

        // when
        queue.add(message);

        // then
        try {
            Thread.sleep(100); // sleep for a time alloted for a message to be
                               // sent
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        verify(client).sendMessageToClientComputer(message);

    }

    static public void main(String... args) {
        SendingQueueTest obj = new SendingQueueTest();
        obj.shouldRecepientBeSentMessageAddedToTheQueue();
    }

}
